<template>
    <!-- 跳转页面的卡片，每排三个 -->
     <div class="page-list">
        <template v-for="(page, index) in pages" :key="index">
            <router-link :to="page.path" v-if="page.showInMenu" class="page-link">
                <el-card class="page-card" shadow="hover">
                    <div class="page-card-content">
                        <div class="page-card-icon">
                            <svg v-html="page.icon" class="card-icon"></svg>
                        </div>
                        <div class="page-card-info">
                            <h3 class="page-card-title">{{ page.title }}</h3>
                            <p class="page-card-description">{{ page.description }}</p>
                        </div>
                    </div>
                </el-card>
            </router-link>
        </template>
     </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { getCurrentRouteList } from '@/utils/RouterUtil';
import { HomeFilled, UserFilled, Document, DataAnalysis } from '@element-plus/icons-vue';

const pages = ref<Array<{title: string, path: string, description: string, icon: string, showInMenu: boolean}>>(getCurrentRouteList());

// 图标映射
const pageIconMap: Record<string, any> = {
    'HomeFilled': HomeFilled,
    'UserFilled': UserFilled,
    'Document': Document
};


</script>

<style scoped>
.page-list {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    padding: 24px;
    justify-content: flex-start;
}

.page-link {
    text-decoration: none;
    color: inherit;
    flex: 0 0 calc(33.333% - 16px);
    min-width: 280px;
    max-width: 400px;
}

.page-card {
    height: 100%;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid #e4e7ed;
}

.page-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
    border-color: #409eff;
}

.page-card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 24px;
    text-align: center;
}

.page-card-icon {
    margin-bottom: 20px;
    color: #409eff;
    size: 40px;
}

.page-card-info {
    width: 100%;
}

.page-card-title {
    font-size: 20px;
    font-weight: 600;
    color: #303133;
    margin: 0 0 12px 0;
}

.page-card-description {
    font-size: 14px;
    color: #909399;
    margin: 0;
    line-height: 1.6;
}

.card-icon {
    width: 48px;
    height: 48px;
    fill: currentColor;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .page-link {
        flex: 0 0 calc(50% - 12px);
    }
}

@media (max-width: 768px) {
    .page-link {
        flex: 0 0 100%;
    }
    
    .page-list {
        padding: 16px;
        gap: 16px;
    }
}
</style>